import 'package:flutter/material.dart';
import 'package:xiongan_app_yy/pages/common/BaseMaterialInfo.dart';
import 'package:xiongan_app_yy/pages/common/TextFieldItem.dart';
import 'package:provider/provider.dart';
import 'package:xiongan_app_yy/provider/automounting_provider.dart';
import 'package:xiongan_app_yy/widgets/comm/left_icon_widget.dart';

class AutoMountingDDetailOne extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _AutoMountingDDetailOne();
  }
}

class _AutoMountingDDetailOne extends State<AutoMountingDDetailOne> {
  Map<String, dynamic> map = Map();

  @override
  Widget build(BuildContext context) {
    map=Provider.of<AutoMountingProvider>(context).detailData;
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        leading: LeftIconWidget(icon: Icons.chevron_left, isize: 36),
        backgroundColor: Color(0XFF00A5F1),
        title: Text(
          "分配货位上架",
          style: TextStyle(fontSize: 18),
        ),
        elevation: 0,
        centerTitle: true,
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: Scrollbar(
              child: SingleChildScrollView(
                child: Column(
                  children: <Widget>[
                    BaseMaterialInfo(
                      imgwid: Image.asset("assets/images/build.png",fit: BoxFit.fill),
                      options: {"materialname":"物资名称","materialcode":"实物ID","baseunitname":"基本单位","planquantity":"计划上架数"},
                      data: map,
                    ),
                    Container(
                      padding: EdgeInsets.all(15),
                      child: Column(
                        children: <Widget>[
                          Visibility(
                            visible: map['devicetypeid'] == '1',
                            child: Container(
                              child: Row(
                                children: <Widget>[
                                  Expanded(
                                    child: TextFieldItem(
                                      hintText: "扫描或输入托盘存放位置"),
                                  ),
                                  Visibility(
                                    visible: !map['issendputdowntask'],
                                    child: Container(
                                      margin: EdgeInsets.only(left: 10),
                                      child: FlatButton(
                                        color: Color(0xFF42AFF0),
                                        padding: EdgeInsets.only(
                                            top: 13,
                                            bottom: 13,
                                            left: 10,
                                            right: 10),
                                        child: Text(
                                          "发送指令下架",
                                          style: TextStyle(
                                              fontSize: 12,
                                              color: Colors.white),
                                        ),
                                        onPressed: () {
                                          print("测试");
                                        },
                                      ),
                                    ),
                                  )
                                ],
                              ),
                            ),
                          ),
                          Visibility(
                            visible: map['devicetypeid'] == '1',
                            child: TextFieldItem(hintText: "输入或扫描托盘存放位置"),
                          ),
                          TextFieldItem(hintText: "输入实际上架数"),
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
          Row(
            children: <Widget>[
              Visibility(
                visible: !map['issendputawaytask'],
                child: Expanded(
                  child: FlatButton(
                    shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.all(Radius.circular(0))),
                    padding: EdgeInsets.all(15),
                    color: Color(0xFF42AFF0),
                    child: Text(
                      "发送上架指令",
                      style: TextStyle(color: Colors.white),
                    ),
                    onPressed: () {
                      print("发送上架指令");
                    },
                  ),
                ),
              ),
              Expanded(
                child: FlatButton(
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(0))),
                  padding: EdgeInsets.all(15),
                  color: Color(0xffda732a),
                  child: Text(
                    "选择货位",
                    style: TextStyle(color: Colors.white),
                  ),
                  onPressed: () {
                    Navigator.of(context).pushNamed("/select_location");
                  },
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}
